package de.szut.tictactoe.view;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import javax.swing.BorderFactory;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.SwingConstants;

import javax.swing.WindowConstants;
import javax.swing.border.LineBorder;
import javax.swing.border.TitledBorder;
import javax.swing.SwingUtilities;


/**
* This code was edited or generated using CloudGarden's Jigloo
* SWT/Swing GUI Builder, which is free for non-commercial
* use. If Jigloo is being used commercially (ie, by a corporation,
* company or business for any purpose whatever) then you
* should purchase a license for each developer using Jigloo.
* Please visit www.cloudgarden.com for details.
* Use of Jigloo implies acceptance of these licensing terms.
* A COMMERCIAL LICENSE HAS NOT BEEN PURCHASED FOR
* THIS MACHINE, SO JIGLOO OR THIS CODE CANNOT BE USED
* LEGALLY FOR ANY CORPORATE OR COMMERCIAL PURPOSE.
*/
public class MainJFrame extends javax.swing.JFrame {
	private boolean isX;
	private JLabel jLabel5;
	private JLabel jLabel9;
	private JLabel jLabel8;
	private JLabel jLabel7;
	private JLabel jLabel6;
	private JLabel jLabel4;
	private JLabel jLabel3;
	private JLabel jLabel2;
	private JLabel jLabel1;
	private JPanel jPanel1;

	/**
	* Auto-generated main method to display this JFrame
	*/
	public static void main(String[] args) {
		SwingUtilities.invokeLater(new Runnable() {
			public void run() {
				MainJFrame inst = new MainJFrame();
				inst.setLocationRelativeTo(null);
				inst.setVisible(true);
			}
		});
	}
	
	public MainJFrame() {
		super();
		initGUI();
	}
	
	private void initGUI() {
		try {
			setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
			getContentPane().setLayout(null);
			this.setEnabled(false);
			{
				jPanel1 = new JPanel();
				getContentPane().add(jPanel1);
				jPanel1.setBounds(12, 12, 244, 212);
				jPanel1.setLayout(null);
				jPanel1.setBorder(BorderFactory.createTitledBorder(null, "Spielfeld", TitledBorder.LEADING, TitledBorder.DEFAULT_POSITION));
				{
					jLabel1 = new JLabel();
					jPanel1.add(jLabel1);
					jLabel1.setBounds(12, 19, 61, 47);
					jLabel1.setOpaque(true);
					jLabel1.setBackground(new java.awt.Color(128,255,128));
					jLabel1.setBorder(new LineBorder(new java.awt.Color(0,0,0), 1, false));
					jLabel1.setFont(new java.awt.Font("Tahoma",0,16));
					jLabel1.setHorizontalAlignment(SwingConstants.CENTER);
					jLabel1.addMouseListener(new MouseAdapter() {
						public void mouseClicked(MouseEvent evt) {
							jLabel1MouseClicked(evt);
						}
					});
				}
				{
					jLabel2 = new JLabel();
					jPanel1.add(jLabel2);
					jLabel2.setBackground(new java.awt.Color(128,255,128));
					jLabel2.setOpaque(true);
					jLabel2.setBorder(new LineBorder(new java.awt.Color(0,0,0), 1, false));
					jLabel2.setBounds(79, 19, 61, 47);
					jLabel2.setFont(new java.awt.Font("Tahoma",0,16));
					jLabel2.setHorizontalAlignment(SwingConstants.CENTER);
					jLabel2.addMouseListener(new MouseAdapter() {
						public void mouseClicked(MouseEvent evt) {
							jLabel2MouseClicked(evt);
						}
					});
				}
				{
					jLabel3 = new JLabel();
					jPanel1.add(jLabel3);
					jLabel3.setBackground(new java.awt.Color(128,255,128));
					jLabel3.setOpaque(true);
					jLabel3.setBorder(new LineBorder(new java.awt.Color(0,0,0), 1, false));
					jLabel3.setBounds(146, 19, 61, 47);
					jLabel3.setFont(new java.awt.Font("Tahoma",0,16));
					jLabel3.setHorizontalAlignment(SwingConstants.CENTER);
					jLabel3.addMouseListener(new MouseAdapter() {
						public void mouseClicked(MouseEvent evt) {
							jLabel3MouseClicked(evt);
						}
					});
				}
				{
					jLabel4 = new JLabel();
					jPanel1.add(jLabel4);
					jLabel4.setBackground(new java.awt.Color(128,255,128));
					jLabel4.setOpaque(true);
					jLabel4.setBorder(new LineBorder(new java.awt.Color(0,0,0), 1, false));
					jLabel4.setBounds(12, 72, 61, 47);
					jLabel4.setFont(new java.awt.Font("Tahoma",0,16));
					jLabel4.setHorizontalAlignment(SwingConstants.CENTER);
					jLabel4.addMouseListener(new MouseAdapter() {
						public void mouseClicked(MouseEvent evt) {
							jLabel4MouseClicked(evt);
						}
					});
				}
				{
					jLabel5 = new JLabel();
					jPanel1.add(jLabel5);
					jLabel5.setBackground(new java.awt.Color(128,255,128));
					jLabel5.setOpaque(true);
					jLabel5.setBorder(new LineBorder(new java.awt.Color(0,0,0), 1, false));
					jLabel5.setBounds(79, 72, 61, 47);
					jLabel5.setFont(new java.awt.Font("Tahoma",0,16));
					jLabel5.setHorizontalAlignment(SwingConstants.CENTER);
					jLabel5.addMouseListener(new MouseAdapter() {
						public void mouseClicked(MouseEvent evt) {
							jLabel5MouseClicked(evt);
						}
					});
				}
				{
					jLabel6 = new JLabel();
					jPanel1.add(jLabel6);
					jLabel6.setBackground(new java.awt.Color(128,255,128));
					jLabel6.setOpaque(true);
					jLabel6.setBorder(new LineBorder(new java.awt.Color(0,0,0), 1, false));
					jLabel6.setBounds(146, 72, 61, 47);
					jLabel6.setFont(new java.awt.Font("Tahoma",0,16));
					jLabel6.setHorizontalAlignment(SwingConstants.CENTER);
					jLabel6.addMouseListener(new MouseAdapter() {
						public void mouseClicked(MouseEvent evt) {
							jLabel6MouseClicked(evt);
						}
					});
				}
				{
					jLabel7 = new JLabel();
					jPanel1.add(jLabel7);
					jLabel7.setBackground(new java.awt.Color(128,255,128));
					jLabel7.setOpaque(true);
					jLabel7.setBorder(new LineBorder(new java.awt.Color(0,0,0), 1, false));
					jLabel7.setBounds(12, 125, 61, 47);
					jLabel7.setFont(new java.awt.Font("Tahoma",0,16));
					jLabel7.setHorizontalAlignment(SwingConstants.CENTER);
					jLabel7.addMouseListener(new MouseAdapter() {
						public void mouseClicked(MouseEvent evt) {
							jLabel7MouseClicked(evt);
						}
					});
				}
				{
					jLabel8 = new JLabel();
					jPanel1.add(jLabel8);
					jLabel8.setBackground(new java.awt.Color(128,255,128));
					jLabel8.setOpaque(true);
					jLabel8.setBorder(new LineBorder(new java.awt.Color(0,0,0), 1, false));
					jLabel8.setBounds(79, 125, 61, 47);
					jLabel8.setFont(new java.awt.Font("Tahoma",0,16));
					jLabel8.setHorizontalAlignment(SwingConstants.CENTER);
					jLabel8.addMouseListener(new MouseAdapter() {
						public void mouseClicked(MouseEvent evt) {
							jLabel8MouseClicked(evt);
						}
					});
				}
				{
					jLabel9 = new JLabel();
					jPanel1.add(jLabel9);
					jLabel9.setBackground(new java.awt.Color(128,255,128));
					jLabel9.setOpaque(true);
					jLabel9.setBorder(new LineBorder(new java.awt.Color(0,0,0), 1, false));
					jLabel9.setBounds(146, 125, 61, 47);
					jLabel9.setFont(new java.awt.Font("Tahoma",0,16));
					jLabel9.setHorizontalAlignment(SwingConstants.CENTER);
					jLabel9.addMouseListener(new MouseAdapter() {
						public void mouseClicked(MouseEvent evt) {
							jLabel9MouseClicked(evt);
						}
					});
				}
			}
			pack();
			this.setSize(288, 287);
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
	
	private void makeMove(JLabel source) {
		if (isX)
		{
			source.setText("X");
		}
		else
		{
			source.setText("O");
		}
		
	}
	
	
	private void jLabel1MouseClicked(MouseEvent evt) {
		makeMove((JLabel)evt.getSource());
	}
	
	

	private void jLabel2MouseClicked(MouseEvent evt) {
		makeMove((JLabel)evt.getSource());
	}
	
	private void jLabel3MouseClicked(MouseEvent evt) {
		makeMove((JLabel)evt.getSource());
	}
	
	private void jLabel4MouseClicked(MouseEvent evt) {
		makeMove((JLabel)evt.getSource());
	}
	
	private void jLabel5MouseClicked(MouseEvent evt) {
		makeMove((JLabel)evt.getSource());
	}
	
	private void jLabel6MouseClicked(MouseEvent evt) {
		makeMove((JLabel)evt.getSource());
	}
	
	private void jLabel7MouseClicked(MouseEvent evt) {
		makeMove((JLabel)evt.getSource());
	}
	
	private void jLabel8MouseClicked(MouseEvent evt) {
		makeMove((JLabel)evt.getSource());
	}
	
	private void jLabel9MouseClicked(MouseEvent evt) {
		makeMove((JLabel)evt.getSource());
	}
	

}
